package com.fc.happyteam.job;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * Created by charles on 2017/10/24.
 */
@Component
@Configurable
@EnableScheduling
public class SpringScheduleTask {
    private static final Logger log = LoggerFactory.getLogger(SpringScheduleTask.class);

    //每天早晨1点8分执行一次
    //@Scheduled(cron = "0 8 1 * * *")
    //每1分钟执行一次
    @Scheduled(cron = "0 */1 *  * * * ")
    public void runJobByCron() {
        log.info("Scheduling Tasks SampleScheduleTask : start at: " + new Date());
        log.info("Starting ...");
        //DO SOMETHING
        log.info("completed");
        log.info("Tasks SampleScheduleTask: complet+e at: " + new Date());
    }
}